package org.gpp.proj1.ui.gui.command;

import javax.swing.JOptionPane;

import org.gpp.proj1.ui.gui.SRGGUIView;

public class LoadProfileCommand extends AbstractGUICommand implements SRGGUICommand {

	public LoadProfileCommand(SRGGUIView view) {
		super(view);
	}

	public void execute() {

		Object profile = view.getSelectedProfile();
		
		if( profile == null ) {
			JOptionPane.showMessageDialog( null, "No profile is selected.",
					"Error", JOptionPane.ERROR_MESSAGE );
		} else {
			try { 
				view.getController().loadProfile( (String) profile );
			} catch( IllegalArgumentException iae ) {
				JOptionPane.showMessageDialog( null, iae.getMessage(),
						"Error", JOptionPane.ERROR_MESSAGE );	
			}
		}
	}

}
